<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>对象</title>
    <script src="js/traceur.js"></script>
    <script src="js/bootstrap.js"></script>
    <script type="module">
        //Es5
        var x = {x: 12};
        var y = Object.create(x,{y: {value: 13}});
        console.log(y.x); // 12
        console.log(y.y); // 13

        //es6
        let a = {a: 12, __proto__: {b:13}};
        console.log(a.a); //12
        console.log(a.b); //13

        //Object.is()方法
        console.log(Object.is(0, -0)); //false
        console.log(0 === -0); // true
        console.log(Object.is(NaN, 0/0)); //true
        console.log(NaN === 0/0); //false
        console.log(Object.is(NaN, NaN)); //true
        console.log(NaN ===NaN); //false

        //给y1对象添加x1对象
        let x1 = {x: 12};
        let y1 = {y: 13};
        Object.setPrototypeOf(y1, x1)
        console.log(y1.x); //"12"
        console.log(y1.y); // "13"

        let x2 = {x: 12};
        let y2 = {y: 13, __proto__: x2};
        let z2 = {z: 14, get b() {return 2;}, q: {}};
        Object.defineProperty(z2, "z", {enumerable: false});
        let m = {};
        Object.assign(m, y2, z2);
        console.log(m.y); // 13
        console.log(m.z); // undefined
        console.log(m.b); // 2
        console.log(m.x); // undefined
        console.log(m.q == z2.q); // true

    </script>
</head>
<body>

</body>
</html>